import java.util.Arrays;
import java.util.Random;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * Author:  LiuTao
 * Version: 1.0
 * Date:    2023-10-24  10:12
 */
public class Test {
    public static void main(String[] args) {
        Random random = new Random();
        int[] num = new int[20];
        int count = 0;
        for(int i = 0; i < num.length; i++) {
            num[i] = random.nextInt(100);
        }
        System.out.println("生成的数组：" + Arrays.toString(num));
        for(int i = 0; i < num.length; i++) {
            for(int j = 0; j < num.length - i - 1; j++) {
                if (num[j] > num[j + 1]) {
                    int temp = num[j];
                    num[j] = num[j + 1];
                    num[j + 1] = temp;
                }
            }
        }
        System.out.println("排序后的数组：");
        for(int i = 0; i < num.length; i++) {
            System.out.print(num[i] + " ");
            count++;
            if(count % 5 == 0) {
                System.out.println();
            }
        }
    }
}
